package com.guanghua.brick.html.tag;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.guanghua.brick.html.BindControl;
import com.guanghua.brick.html.IContent;
import com.guanghua.brick.html.IControl;
import com.guanghua.brick.html.IDepend;
import com.guanghua.brick.html.IReplace;

public class ControlBindTag extends BodyTagSupport implements IControl {
	
	private static Log logger = LogFactory.getLog(ControlBindTag.class);
	private BindControl control = new BindControl();
	
	public int doEndTag() throws JspException {
		try {
			pageContext.getOut().println(
					build((HttpServletRequest)pageContext.getRequest(), (HttpServletResponse)pageContext.getResponse(), pageContext));
		} catch (IOException e) {
			logger.error("io exception on print bind area html", e);
		}
		return BodyTagSupport.EVAL_PAGE;
	}

	public void addBindMap(String currentPageField, String optionAttributeName) {
		control.addBindMap(currentPageField, optionAttributeName);
	}

	public String build(HttpServletRequest request, HttpServletResponse response, PageContext pageContext) {
		return control.build(request, response, pageContext);
	}

	public IContent getContent() {
		return control.getContent();
	}

	public String getData() {
		return control.getData();
	}

	public String getDataSource() {
		return control.getDataSource();
	}

	public List<IDepend> getDepends() {
		return control.getDepends();
	}

	public String getFunction() {
		return control.getFunction();
	}

	public String getHtml() {
		return control.getHtml();
	}

	public String getId() {
		return control.getId();
	}

	public String getName() {
		return control.getName();
	}

	public String getOptionName() {
		return control.getOptionName();
	}

	public List<IReplace> getReplaces() {
		return control.getReplaces();
	}

	public String getUrl() {
		return control.getUrl();
	}

	public int getWindowHeight() {
		return control.getWindowHeight();
	}

	public String getWindowName() {
		return control.getWindowName();
	}

	public int getWindowWidth() {
		return control.getWindowWidth();
	}

	public boolean isModalDialog() {
		return control.isModalDialog();
	}

	public void setContent(IContent content) {
		control.setContent(content);
	}

	public void setData(String data) {
		control.setData(data);
	}

	public void setDataSource(String dataSource) {
		control.setDataSource(dataSource);
	}

	public void setDepends(List<IDepend> depends) {
		control.setDepends(depends);
	}

	public void setFunction(String function) {
		control.setFunction(function);
	}

	public void setHtml(String html) {
		control.setHtml(html);
	}

	public void setId(String id) {
		control.setId(id);
	}

	public void setModalDialog(boolean isModalDialog) {
		control.setModalDialog(isModalDialog);
	}

	public void setName(String name) {
		control.setName(name);
	}

	public void setOptionName(String optionName) {
		control.setOptionName(optionName);
	}

	public void setReplaces(List<IReplace> replaces) {
		control.setReplaces(replaces);
	}

	public void setUrl(String url) {
		control.setUrl(url);
	}

	public void setWindowHeight(int windowHeight) {
		control.setWindowHeight(windowHeight);
	}

	public void setWindowName(String windowName) {
		control.setWindowName(windowName);
	}

	public void setWindowWidth(int windowWidth) {
		control.setWindowWidth(windowWidth);
	}
	
}
